<template>
  <!-- 短信发送查询 -->
  <section class="page message-send-record-query">
    <data-form :model="searchModel" @onSearch="refreshData" :page="pageService">
      <template slot="inputs">
        <el-form-item label="订单编号" prop="caseNumber">
          <el-input v-model="searchModel.caseNumber"></el-input>
        </el-form-item>
        <el-form-item label="批次号" prop="batchNumber">
          <el-input v-model.trim="searchModel.batchNumber"></el-input>
        </el-form-item>
        <el-form-item label="委托方" prop="principalId">
          <el-select v-model="searchModel.principalId" placeholder="请选择" clearable>
            <el-option v-for="{index,name,id} in principalList.content" :key="index" :label="name" :value="id"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="客户姓名" prop="personalName">
          <el-input v-model.trim="searchModel.personalName"></el-input>
        </el-form-item>
        <el-form-item label="身份证号" prop="idCard">
          <el-input v-model="searchModel.idCard"></el-input>
        </el-form-item>
        <el-form-item label="业务团队" prop="partnerName">
          <el-input v-model.trim="searchModel.partnerName"></el-input>
        </el-form-item>
        <el-form-item label="贷款银行" prop="bankName">
          <el-input v-model.trim="searchModel.bankName"></el-input>
        </el-form-item>
        <el-form-item label="发送人" prop="operatorRealName">
          <el-input v-model="searchModel.operatorRealName"></el-input>
        </el-form-item>
        <el-form-item label="发送时间" prop="createTime">
          <el-date-picker type="daterange" :editable="false" v-model="searchModel.createTime" placeholder="选择日期时间" clearable>
          </el-date-picker>
        </el-form-item>
        <el-form-item label="发送状态" prop="messageStatus">
          <el-select v-model="searchModel.messageStatus" placeholder="请选择" clearable>
            <el-option v-for="{index,name,code} in $dict.getDictData('MessageStatus')" :key="index" :label="name" :value="code"></el-option>
          </el-select>
        </el-form-item>
      </template>
    </data-form>

    <data-box :data="dataSet" @onPageChange="refreshData" :page="pageService">
      <template slot="columns">
        <!--数据列区域-->
                <el-table-column prop="caseNumber" label="订单编号" :min-width="$helper.getColumnWidth(6)">
          <template slot-scope="scope">
            <el-button type="text" @click="openExecutionPage(scope.row)">{{scope.row.caseNumber}}</el-button>
          </template>
        </el-table-column>
        <el-table-column prop="batchNumber" label="批次号" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip></el-table-column>
        <el-table-column prop="principalName" label="委托方" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip></el-table-column>
        <el-table-column prop="personalName" label="客户姓名" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="idCard" label="身份证号" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="mobileNo" label="手机号" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="partnerName" label="业务团队" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="bankName" label="贷款银行" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="messageContent" label="短信内容" :min-width="$helper.getColumnWidth(7)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="operatorRealName" label="发送人" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="createTime" label="发送时间" :formatter="(row) => $filter.dateTimeFormat(row.createTime)" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="messageStatus" label="发送状态" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
          <template slot-scope='scope'>
            <span>{{scope.row.messageStatus | dictConvert('MessageStatus')}}</span>
          </template>
        </el-table-column>
      </template>
    </data-box>
  </section>
</template>

<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";
import { Auth, Layout, Dependencies } from "~/core/decorator";
import { PageService } from "~/utils/page.service";
import DataForm from "~/components/common/data-form.vue";
import DataBox from "~/components/common/data-box.vue";
import { SortService } from "~/utils/sort.service";
import NumberRange from "~/components/common/number-range.vue";
import { SynthesizeQueryService } from "~/services/domain-service/synthesize-query.service";
import { namespace, Getter, Mutation,State } from "vuex-class";
import { MENU_CHANNEL } from "../../config/enum.config";

@Layout("workspace")
@Component({
  components: {


    NumberRange
  }
})
export default class MessageSendRecordQuery extends Vue {
  @Dependencies(PageService) private pageService: PageService;
  @Dependencies(SortService) private sortService: SortService;
  @Dependencies(SynthesizeQueryService)
  private synthesizeQueryService: SynthesizeQueryService;
  @State private principalList: any;
  private searchModel: any = {
    caseNumber: "",
    batchNumber: '',
    principalName: '',
    personalName: "",
    idCard: '',
    messageStatus: "",
    operatorRealName: "",
    createTime: [],
    partnerName: '',
    bankName: '',
  };

  private dataSet: any[] = [];

  private refreshData() {
    this.synthesizeQueryService
      .queryMessageSendRecord(this.searchModel, this.pageService)
      .subscribe(data => (this.dataSet = data));
  }
  /**
   * 进入查看执行页
   */
  private openExecutionPage(row) {
    this.$router.openCaseDetail(row.caseId, {
      menuChannel: MENU_CHANNEL.Query_case_query,
      hiddenCaseList: true,
      hiddenAction: true
    });
  }
  private mounted() {
    this.refreshData();
  }

}
</script>
<style lang="less">
</style>
